package demo3;

import java.util.Stack;

public class Test {
    public static void main(String[] args) {
        String[] tokens = new String[3];
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < tokens.length; i++) {
            if (isDigit(tokens[i])) {
                stack.push(Integer.valueOf(tokens[i]));
            } else {
                int num1 = stack.pop();
                int num2 = stack.pop();
                switch (tokens[i]) {
                    case "+" :
                        stack.push(num2 + num1);
                        break;
                    case "-" :
                        stack.push(num2 - num1);
                        break;
                    case "*" :
                        stack.push(num2 * num1);
                        break;
                    case "/" :
                        stack.push(num2 / num1);
                        break;
                }
            }
        }
        //return stack.pop();
    }
    public static boolean isDigit (String str) {
        if (str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/")) {
            return false;
        }
        return true;
    }
}
